package com.platform.controller;

import com.platform.entity.GoodsEntity;
import com.platform.entity.HotelEntity;
import com.platform.service.GoodsQrCodeService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/goodsQrCode")
public class GoodsQrCodeController {

    @Autowired
    private GoodsQrCodeService goodsQrCodeService;
    /**
     * 查看所有商品列表
     */
    @RequestMapping("/queryAllGoods")
    public R queryAll(@RequestParam Map<String, Object> params) {
        params.put("isDelete", 0);
        params.put("isShow", 1);
        params.put("flag", "true");
        Query query = new Query(params);
        List<GoodsEntity> list = goodsQrCodeService.queryList(params);
        int total = goodsQrCodeService.queryTotal(query);
        PageUtils pageUtil = new PageUtils(list,total,query.getLimit(),query.getPage());
        return R.ok().put("page", pageUtil);
    }

    @RequestMapping("/info")
    public R info() {
        Map<String, Object> params = new HashMap<>();
        params.put("isDelete", 0);
        params.put("isShow", 1);
        params.put("flag", "false");
        List<GoodsEntity> list = goodsQrCodeService.queryList(params);
        return R.ok().put("list", list);
    }

    /*
    * 新增商品二维码
    * */
    @RequestMapping("/addGoodsQrCode")
    public R addHotel(@RequestBody GoodsEntity goodsEntity)  {
        goodsQrCodeService.update(goodsEntity);
        return R.ok();
    }
}
